function dec2binary() {
    const num = 6

    const b = num.toString(2)
    console.log(b)
    const res = b.padStart(32, "0")
    console.log(res)

    const s = "011"
    const max = s.length
    const nArr = []
    for (let i = 0; i < max; i++) {
        if (s[max - i] == "1") {
            nArr.push(i)
        }
    }
    console.log(nArr)
}

const isBitSet = (num: number, bit: number): boolean => {
    console.log(num.toString(2), (1 << bit).toString(2))
    return (num & (1 << bit)) !== 0;
}

function comparebit() {
    const num = 0b1011
    console.log(num)
    console.log("===")
    console.log(isBitSet(num, 0))
    console.log(isBitSet(num, 1))
    console.log(isBitSet(num, 2))
    console.log(isBitSet(num, 3))
    console.log(isBitSet(num, 4))
}

export function test_binary() {
    console.log("===>Test: test_binary()")
    // dec2binary()
    comparebit()
}
